package com.glsc.ngateway.platform.domain.costallocation;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * @author guoj
 * @description: 历史应用信息
 * @date 2024/8/21 9:50
 */
@Data
@Entity
@Table(name = "t_his_ipdetail_info")
@AllArgsConstructor
@NoArgsConstructor
@Builder
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class HisIpDetailInfo {

    @ApiModelProperty(value = "id")
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "l_id", columnDefinition = "int(11) comment '主键id'")
    private Long id;

    @ApiModelProperty(value = "IP信息id")
    @Column(name = "vc_ipinfo_id", columnDefinition = "varchar(10) comment 'IP信息id'")
    private Long ipInfoId;
    @ApiModelProperty(value = "系统编号")
    @Column(name = "vc_system_classno", columnDefinition = "varchar(50) comment '系统编号'")
    private String systemClassNo;
    //下面这三项在list页面 可根据系统编号去系统新标动态查询后填充
    //但是有查询查询条件时麻烦
    @ApiModelProperty(value = "系统名称")
    @Column(name = "vc_system_name", columnDefinition = "varchar(50) comment '系统名称'")
    private String systemName;
    @ApiModelProperty(value = "系统大类")
    @Column(name = "vc_main_class", columnDefinition = "varchar(10) comment '系统大类'")
    private String mainClass;
    @ApiModelProperty(value = "系统小类")
    @Column(name = "vc_system_class", columnDefinition = "varchar(10) comment '系统小类'")
    private String systemClass;
    @ApiModelProperty(value = "操作人")
    @Column(name = "vc_operator", columnDefinition = "varchar(50) comment '操作人'")
    private String operator;
    //应用类别的删除操作为真删除，删除后此处无法通过id找到对应值，
    // 因此此处同时保存了应用类别id和值。
    // 应用类别删除后，通过id无法从应用类别表中找到数据，但此处应用类别仍有值
    @ApiModelProperty(value = "应用类别")
    @Column(name = "vc_component_category", columnDefinition = "varchar(50) comment '应用类别'")
    private String componentCategory;
    @ApiModelProperty(value = "应用类别Id")
    @Column(name = "vc_component_category_id", columnDefinition = "int(11) comment '应用类别Id'")
    private Long componentCategoryId;
    @ApiModelProperty(value = "应用名称")
    @Column(name = "vc_component_name", columnDefinition = "varchar(50) comment '应用名称'")
    private String componentName;

    //默认带出应用类别路径（必填）
    @ApiModelProperty(value = "安装路径")
    @Column(name = "vc_component_path", columnDefinition = "varchar(50) comment '安装路径'")
    private String componentPath;
    //主 备 yesno
    @ApiModelProperty(value = "主灾标识 主备yesno")
    @Column(name = "vc_main_backup", columnDefinition = "varchar(10) comment '主灾标识'")
    private String mainOrBackup;
    //正常 故障 yesno
    @ApiModelProperty(value = "运行状态 正常故障yesno")
    @Column(name = "vc_run_status", columnDefinition = "varchar(10) comment '运行状态'")
    private String runStatus;
    // 是否 yesno
    @ApiModelProperty(value = "是否独占 是否yesno")
    @Column(name = "vc_exclusive", columnDefinition = "varchar(10) comment '是否独占'")
    private String exclusive;
    @ApiModelProperty(value = "占用比例")
    @Column(name = "en_source_allocation", columnDefinition = "decimal(20,4) comment '占用比例'")
    private BigDecimal sourceAllocation;

    @ApiModelProperty(value = "创建时间")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @Column(name = "dt_create_time", columnDefinition = "datetime comment '创建时间'")
    protected LocalDateTime createTime;
}
